create table ${table.tableNameSnake}
(
<#list table.fields as field>
    ${field.name}    ${field.type}<#if field.default??> default ${field.default}</#if><#if field.notNull> not null</#if><#if field_has_next>,</#if>
</#list>
<#if table.primaryKey?size gt 0>,
    constraint PK_${table.tableNameSnake}
        primary key (
            <#list table.primaryKey as pk>${table.fields?filter(f -> f.nameCamel == pk)[0].name}<#if pk_has_next>, </#if></#list>
        )
</#if>
);

<#-- 字段注释 -->
<#list table.fields as field>
<#if field.commentCn?? && field.commentCn?length gt 0>
comment on column ${table.tableNameSnake}.${field.name} is '${field.commentCn}|${field.commentEn}';
</#if>
</#list>

<#-- 索引定义 -->
<#list table.indexes as idx>
create index ${idx.name}
    on ${table.tableNameSnake} (<#list idx.fields as f>${table.fields?filter(field -> field.nameCamel == f)[0].name}<#if f_has_next>, </#if></#list>)
;
</#list>

<#-- 
  本模板用于批量生成Oracle数据库建表脚本。
  示例数据结构：
  {
    "table": {
      "tableNameCamel": "AcmCddt",
      "tableNameSnake": "T_ACM_CDDT",
      "tableCommentCn": "存款收支明细表",
      "tableCommentEn": "Deposit and Withdrawal Details Table",
      "fields": [
        {"nameCamel": "jrnNo", "name": "JRN_NO", "type": "VARCHAR2(32)", "commentCn": "流水号", "commentEn": "Journal number"},
        {"nameCamel": "sysDt", "name": "SYS_DT", "type": "DATE", "commentCn": "系统日期", "commentEn": "System date"}
      ],
      "primaryKey": ["jrnNo", "jrnSeq", "acDt"],
      "indexes": [
        {"name": "NI1_T_ACM_CDDT", "fields": ["sepCd", "acDt"]},
        {"name": "NI2_T_ACM_CDDT", "fields": ["sysDt", "sepCd"]}
      ]
    }
  }
  变量说明：
    table.tableNameSnake      表名
    table.fields              字段列表（含name、type、commentCn、commentEn等）
    table.primaryKey          主键字段列表（nameCamel）
    table.indexes             索引列表（含索引名、字段列表）
-->